<?php
header("Content-Type:text/html;charset=utf-8");
include('db-conn.php');
$user=$_POST['name'];
$pass=$_POST['pass'];
$tel=$_POST['tel'];
$sname=$_POST['sname'];
$class=$_POST['class'];
//$conn=mysqli_connect('localhost','root','root');
$zhuce="insert into jiuye.user(name,s_name,password,tel,class,time) values('$user','$sname','$pass',$tel,'$class',now());";
$cha="select * from jiuye.user where name='$user';";
$panduan=mysqli_fetch_assoc(mysqli_query($conn,$cha));
var_dump($panduan[name]);
if ($panduan[name] == $user){
   echo "<script>alert('用户名已存在');window.location.href='regist.html';</script>";
}else{
  mysqli_query($conn,$zhuce);
  echo "<script>alert('创建用户成功');window.location.href='index.html';</script>";
   
}
mysqli_close($conn);
?>